<?php

require "../src/utils.php";

use PHPUnit\Framework\TestCase;
use pUtils\utils;

class utilsTest extends TestCase
{
    public function testIsNull()
    {
        $this->assertEquals(2, utils::isNull(1, ""));
    }

    public function testIsEmpty()
    {
        $this->assertEquals(2, utils::isNull(1, ""));
    }

    public function testGetValues()
    {
        $this->assertEquals(["a", null], utils::getVals(["a" => "a"], "a", "b"));
    }

    public function testEvl()
    {
        $this->assertEquals(5, utils::evl([], null, "", 5, ["a"]));
    }

    public function testIsEmail()
    {
        $this->assertTrue(!!utils::isEmail("aa@q.com"));
        $this->assertFalse(utils::isAllEmail("aa@q.com", "a"));
    }

    public function testIsUrl()
    {
        $this->assertTrue(!!utils::isUrl("https://aa.com"));
        $this->assertTrue(!!utils::isUrl("https://192.168.0"));
        $this->assertFalse(utils::isAllUrl("aa@q.com", "aaa.com"));
    }

    public function testIsIp()
    {
        $this->assertTrue(!!utils::isIp("192.168.110.5"));
        $this->assertFalse(utils::isAllIp("aa@q.com", "aaa.com"));
    }

    public function testIsMac()
    {
        $this->assertTrue(!!utils::isMac("FF-AA-14-F1-80-C9"));
        $this->assertFalse(utils::isAllMac("FC-AA-14-F1-80-C9", "FC:AA:14:F1:80:C9", "fc-aa-14-f1-80-c9", "fc aa 14 f1 80 c9"));
    }
}
